/// 连接类型枚举
enum ConnectionType {
  /// USB连接
  usb,

  /// WiFi连接
  wifi,
}

/// 连接类型扩展方法
extension ConnectionTypeExtension on ConnectionType {
  /// 获取显示名称
  String get displayName {
    switch (this) {
      case ConnectionType.usb:
        return 'USB连接';
      case ConnectionType.wifi:
        return 'WiFi连接';
    }
  }

  /// 获取图标名称（Material Icons）
  String get iconName {
    switch (this) {
      case ConnectionType.usb:
        return 'usb';
      case ConnectionType.wifi:
        return 'wifi';
    }
  }
}

/// 连接方式模型
///
/// 表示一种相机连接方式的详细信息
class ConnectionMethod {
  /// 连接类型
  final ConnectionType type;

  /// 显示名称
  final String displayName;

  /// 描述信息
  final String description;

  /// 图标名称
  final String iconName;

  const ConnectionMethod({
    required this.type,
    required this.displayName,
    required this.description,
    required this.iconName,
  });

  /// 创建副本
  ConnectionMethod copyWith({
    ConnectionType? type,
    String? displayName,
    String? description,
    String? iconName,
  }) {
    return ConnectionMethod(
      type: type ?? this.type,
      displayName: displayName ?? this.displayName,
      description: description ?? this.description,
      iconName: iconName ?? this.iconName,
    );
  }

  @override
  String toString() {
    return 'ConnectionMethod(type: ${type.displayName}, name: $displayName)';
  }

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) return true;

    return other is ConnectionMethod &&
        other.type == type &&
        other.displayName == displayName &&
        other.description == description &&
        other.iconName == iconName;
  }

  @override
  int get hashCode {
    return Object.hash(
      type,
      displayName,
      description,
      iconName,
    );
  }
}
